﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InputTesting
{
    public static class FromConsole
    {
        public static double GetDouble(string message)
        {
            double result;
            bool isParsed;

            do
            {
                Console.Write(message);
                isParsed = double.TryParse(Console.ReadLine(), out result);

                if (!isParsed)
                {
                    Console.WriteLine("Please try again.");
                }
            }
            while (!isParsed);

            return result;
        }

        public static int GetInt(string message)
        {
            int result;
            bool isParsed;

            do
            {
                Console.Write(message);
                isParsed = int.TryParse(Console.ReadLine(), out result);

                if (!isParsed)
                {
                    Console.WriteLine("Please try again.");
                }
            }
            while (!isParsed);

            return result;
        }
    }
}
